package com.hunttown.mes.rpc.domain.enums.iot.alarm;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 报警方式：微信/短信/语音/窗口通知
 * created by wangjunfu on 2019/08/19
 */
public enum AlarmMethodEnum {
    W0(0, "微信"),
    W1(1, "短信"),
    W2(2, "窗口通知"),
    W3(3, "微信+窗口通知"),
    W4(4, "微信+短信+窗口通知");

    private final int key;
    private final String value;

    AlarmMethodEnum(int key, String value) {
        this.key = key;
        this.value = value;
    }

    // 根据key获取枚举
    public static String getEnumByKey(int key) {
        String value = "";

        for (AlarmMethodEnum temp : AlarmMethodEnum.values()) {
            if (temp.getKey() == key) {
                value = temp.getValue();
            }
        }

        return value;
    }

    // 将枚举组成Map
    public static Map<Integer, String> getEnumList() {
        Map<Integer, String> map = new HashMap<>();

        for (AlarmMethodEnum temp : AlarmMethodEnum.values()) {
            map.put(temp.getKey(), temp.getValue());
        }

        return map;
    }

    // 将枚举组成Map（因为枚举是公用的，所以不同项目选择的不一样）
    public static Map<Integer, String> getEnumList(List<Integer> keys) {
        Map<Integer, String> map = new HashMap<>();

        for (AlarmMethodEnum temp : AlarmMethodEnum.values()) {
            if (keys.contains(temp.getKey())) {
                map.put(temp.getKey(), temp.getValue());
            }
        }

        return map;
    }

    // key以字符串的形式返回
    public static Map<String, String> getEnumListString() {
        Map<String, String> map = new HashMap<>();

        for (AlarmMethodEnum temp : AlarmMethodEnum.values()) {
            map.put(temp.getKey() + "", temp.getValue());
        }

        return map;
    }

    public int getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }
}
